package com.example.controller;

import com.alibaba.fastjson.JSON;
import com.example.common.basecontroller.BaseController;

import com.example.common.controllerdto.EbizMainProductSaidListDTO;
import com.example.common.dto.ContentModel;
import com.example.common.dto.ResultModel;
import com.example.common.dto.TransResult;
import com.example.common.exception.BusinessException;
import com.example.servcie.EbizMainProductListService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：czx
 * @date ：Created in 2021/6/24 17:54
 * @modified By：
 */
@Slf4j
@RestController
@RequestMapping("/ebizmainproductlist")

public class EbizMainProductListController extends BaseController {
    @Autowired
    private EbizMainProductListService ebizMainProductListService;

    @RequestMapping(value = "/getEbizMainProductList", method = RequestMethod.POST)
    public ResultModel getEbizMainProductList(@RequestBody EbizMainProductSaidListDTO ebizMainProductSaidListDTO){
        log.info("[产说会主讲产品][主讲产品列表查询][请求信息:{}][开始]", JSON.toJSONString(ebizMainProductSaidListDTO));
        long start=System.currentTimeMillis();

        try {
            TransResult transResult=ebizMainProductListService.getEbizMainProductList(ebizMainProductSaidListDTO);
            log.info("[产说会主讲产品][主讲产品列表查询][返回信息:{}][耗时:{}ms][结束]",JSON.toJSONString(transResult),(System.currentTimeMillis() - start));
            return this.resultResponseSuccess(new ContentModel(transResult.getObject()));
        } catch (BusinessException e) {
           log.info("[产说会主讲产品][主讲产品列表查询][异常信息:{}][结束]" ,e,(System.currentTimeMillis() - start));
            return this.resultResponseFault(new ContentModel(e.getTransResult()));
        }

    }

}
